import request from '@/utils/request'

// 0商品分类列表
export function itemizeIndex(data) {
  return request({
    url: '/commodity/itemizeIndex',
    method: 'post',
    data
  })
}

// 1添加商品分类
export function itemizeAdd(data) {
  return request({
    url: '/commodity/itemizeAdd',
    method: 'post',
    data
  })
}

// 2获取商品分类详情
export function itemizeDetails(data) {
  return request({
    url: '/commodity/itemizeDetails',
    method: 'post',
    data
  })
}

// 3编辑商品分类
export function itemizeEdit(data) {
  return request({
    url: '/commodity/itemizeEdit',
    method: 'post',
    data
  })
}

// 4删除商品分类
export function delItemize(data) {
  return request({
    url: '/commodity/delItemize',
    method: 'post',
    data
  })
}

// 5商品分类上下架
export function opItemizeStatus(data) {
  return request({
    url: '/commodity/opItemizeStatus',
    method: 'post',
    data
  })
}

// 5商品分类置顶
export function opItemizeSort(data) {
  return request({
    url: '/commodity/opItemizeSort',
    method: 'post',
    data
  })
}

// 获取资讯列表下拉框用
export function getinformationList(data) {
  return request({
    url: '/banner/getinformationList',
    method: 'post',
    data
  })
}
// 获取发布编辑资讯  模型类型下拉框用
export function getModelType(data) {
  return request({
    url: '/information/getModelType',
    method: 'post',
    data
  })
}
// 获取发布编辑资讯  系列类型下拉框用
export function getSeriesList(data) {
  return request({
    url: '/information/getSeriesList',
    method: 'post',
    data
  })
}

// 6新增编辑 获取商品分类
export function getCommodityTypeOnList(data) {
  return request({
    url: '/commodity/getCommodityTypeOnList',
    method: 'post',
    data
  })
}

// 7新增商品规格
export function detailsDraftAdd(data) {
  return request({
    url: '/commodity/detailsDraftAdd',
    method: 'post',
    data
  })
}

// 8新增商品  编辑规格 每当光标失去焦点时请求
export function detailsDraftUpdate(data) {
  return request({
    url: '/commodity/detailsDraftUpdate',
    method: 'post',
    data
  })
}

// 9 新增商品 规格模块上移下移
export function detailsDraftMove(data) {
  return request({
    url: '/commodity/detailsDraftMove',
    method: 'post',
    data
  })
}

// 10 新增商品 规格模块模块删除
export function detailsDraftDel(data) {
  return request({
    url: '/commodity/detailsDraftDel',
    method: 'post',
    data
  })
}

// 11 新增商品
export function commodityAdd(data) {
  return request({
    url: '/commodity/commodityAdd',
    method: 'post',
    headers: {
    	'Content-Type': 'multipart/form-data',
    	'type': 'upfile'
    },
    data,
    transformRequest: [function(data, headers) {
    	const formData = new FormData()
    	for (const key of Object.keys(data)) {
    		formData.append(key, data[key])
    	}
    	return formData
    }]
  })
}

// 12 清空临时数据   进入新增页面必须请求
export function detailsDraftClean(data) {
  return request({
    url: '/commodity/detailsDraftClean',
    method: 'post',
    data
  })
}
// 13 商品编辑  获取信息
export function commodityDetail(data) {
  return request({
    url: '/commodity/commodityDetail',
    method: 'post',
    data
  })
}
//
export function commodityDetailInitialize(data) {
  return request({
    url: '/commodity/commodityDetailInitialize',
    method: 'post',
    data
  })
}
// 14编辑商品  编辑规格 每当光标失去焦点时请求
export function detailsUpdate(data) {
  return request({
    url: '/commodity/detailsUpdate',
    method: 'post',
    data
  })
}
// 15 编辑商品 规格模块上移下移
export function detailsMove(data) {
  return request({
    url: '/commodity/detailsMove',
    method: 'post',
    data
  })
}
// 16编辑商品 增加规格
export function detailsAdd(data) {
  return request({
    url: '/commodity/detailsAdd',
    method: 'post',
    data
  })
}
// 17 编辑商品 规格模块模块删除
export function detailsDel(data) {
  return request({
    url: '/commodity/detailsDel',
    method: 'post',
    data
  })
}
// 18 编辑商品
export function commodityEdit(data) {
  return request({
    url: '/commodity/commodityEdit',
    method: 'post',
    headers: {
    	'Content-Type': 'multipart/form-data',
    	'type': 'upfile'
    },
    data,
    transformRequest: [function(data, headers) {
    	const formData = new FormData()
    	for (const key of Object.keys(data)) {
    		formData.append(key, data[key])
    	}
    	return formData
    }]
  })
}
// 19商品列表
export function commodityIdx(data) {
  return request({
    url: '/commodity/index',
    method: 'post',
    data
  })
}
// 20商品上下架
export function opCommodityStatus(data) {
  return request({
    url: '/commodity/opCommodityStatus',
    method: 'post',
    data
  })
}
// 21商品删除
export function delCommodity(data) {
  return request({
    url: '/commodity/delCommodity',
    method: 'post',
    data
  })
}

// 22获取推广渠道
export function getReferer(data) {
  return request({
    url: '/commodity/getReferer',
    method: 'post',
    data
  })
}

// 23发布商品获取推广链接以及二维码
export function getCommodityShareUrl(data) {
  return request({
    url: '/commodity/getCommodityShareUrl',
    method: 'post',
    data
  })
}
